Page({

  data: {
    width: 300,
    height: 300,
    renderWidth: 300,
    renderHeight: 300,
    loaded: false,
    spuId: null,
    xrInfo: {
      openType: 'lo',
      imagePath: null,
    },
    options: {
      openTypeOptions: [
        { label: "左内开", value: "li" },
        { label: "左外开", value: "lo" },
        { label: "右内开", value: "ri" },
        { label: "右外开", value: "ro" },
      ]
    }
  },
  onLoad(options) {
    const { spuId } = options;
    this.setData({ spuId })
    const imagePath = '/assets/imgs/door_p02.png'
    const settings = wx.getSystemSetting();
    const info = wx.getSystemInfoSync();
    console.log('settings:', settings, info);
    console.log('getAppBaseInfo: ', wx.getAppBaseInfo())
    console.log('getDeviceInfo: ', wx.getDeviceInfo())
    const width = info.windowWidth;
    const height = info.windowHeight * 0.7;
    const dpi = info.pixelRatio;
    console.log('getSystemInfoSync: ', width, height)
    this.setData({
      width, height,
      renderWidth: width * dpi,
      renderHeight: height * dpi,
      "xrInfo.imagePath": imagePath,
    });
  },
  // handleReady({detail}) {
  //   console.log('handleReady...', detail.value);
  //   this.scene = detail.value;
  // },
  handleLoaded: function ({ detail }) {
    console.log('view handleLoaded: ', detail);
    this.scene = detail;
    this.setData({ loaded: true });
  },
  handleSyncPositions: function ({ detail }) {
    console.log('view handleSyncPositions: ', detail);
    this.setData({ positions: detail });
  },
  onChangeOpenType(e) {
    this.setData({ "xrInfo.openType": e.detail.value });
  },
  handleShare() {
    console.log('handleShare...')
    this.selectComponent('#main-frame').handleShare();
    // 判断当前客户端是否支持分享系统
    // const supported = this.scene.share.supported;
    // console.log('share supported: ', supported)
    // this.scene.share.captureToDataURL();
    // 截取配置，可选`type`为`jpg`或`png`，在为`jpg`时，可配置`0~1`的`quality`
    // 以下是默认值
    // const options: XrFrame.IShareCaptureOptions = {
    //   type: 'jpg',
    //   quality: 0.8
    // };
    // 基础库`3.0.2`以上新增的异步接口，获取原始的`base64`字符串
    // const base64 = await scene.share.captureToDataURLAsync(options);
  },
  handleDown() { },
  handleToVRView() {
    wx.navigateTo({ url: '/pages/xr-frame/xr-vr/index?spuId=' + this.data.spuId })
  },
})